package com.dianqu.weather.web.engine;

import com.dianqu.weather.core.model.WeatherInfo;

public abstract class EngineStrategyAbstract implements EngineStrategy {

	// 1 is the smallest [1,10]
	private int priority = 1;

	protected abstract WeatherInfo format(String resource);

	public WeatherInfo getInfo(String location) {
		String info = getResource(location);
		if (info != null) {
			return format(info);
		}
		return null;
	}

	public String getName() {
		return this.getClass().getName().toLowerCase();
	}

	public int getPriority() {
		return priority;
	}

	protected abstract String getResource(String location);

	public void setPriority(int priority) {
		this.priority = priority;
	}

}
